#encoding:utf-8
from gevent.wsgi import WSGIServer
from api import api_db,api_test
from gevent import monkey;monkey.patch_all()
urls=(
    ("/api","api_test"),
    ("/api/db","api_db"),
)
#函数01
def Application(environ, start_response):
    path = environ['PATH_INFO']
    # print path+environ['QUERY_STRING']
    for url,app in urls:
        #match = re.search(regex, path)
        if path ==url:
            app=globals()[app]
            return app(environ, start_response)

    start_response("404 NOT FOUND", [('Content-type', 'text/plain')])
    return ["404 ,page dose not exists"]



httpd = WSGIServer(('0.0.0.0', 8000),Application)
# httpd = WSGIServer(('0.0.0.0', 8000),Application,log=False)
print "Serving HTTP on port 8000..."
httpd.serve_forever()
